﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DDLParser.model;
using DDLParser.sqlserver;

namespace DDLParser
{
    public class DDLParser : IDDLParser
    {
        public DDLParser()
        {
        }

        public ActionResultDto<List<ClassSchema>> Parse(DDLParserDto dto)
        {
            ActionResultDto<List<ClassSchema>> result = new ActionResultDto<List<ClassSchema>>();
            try
            {
                if (dto.Stream == null)
                {
                    throw new Exception("Error : input data is null");
                }

                SqlServerParser parser = new SqlServerParser();
                List<ClassSchema> data = parser.Parse(dto.Stream);
                result.Data = data;
                result.Status = true;
                result.ErrorMessage = "";
            }
            catch (Exception ex)
            {
                result.Status = false;
                result.ErrorMessage = ex.Message;

            }
            return result;
        }
        
    }
}
